/**
 * 用户-角色中间表模型
 */
module.exports = (app) => {
  const { STRING, BIGINT, BOOLEAN, DATE, DOUBLE } = app.Sequelize
  const UserRole = app.model.define('user_role', {
    id: {
      type: BIGINT(20),
      autoIncrement: true,
      primaryKey: true,
    },
    userId: {
      type: BIGINT(20),
      allowNull: true,
    },
    roleId: {
      type: BIGINT(20),
      allowNull: true,
    },
    created: {
      type: DATE,
      allowNull: true,
      defaultValue: app.Sequelize.NOW
    },
    creator: {
      type: STRING(36),
      allowNull: true,
    },
    edited: {
      type: DATE,
      allowNull: true,
    },
    editor: {
      type: STRING(36),
      allowNull: true,
    },
    deleted: {
      type: DOUBLE,
      allowNull: true,
    },
  },
    {
      freezeTableName: true, // Model 对应的表名将与model名相同
      timestamps: false,
    })

  return UserRole
}